﻿﻿<template>
    <el-card class="form-container">
        <el-form :model="dataForm" ref="dataForm" :rules="dataRule"  @keyup.enter.native="dataFormSubmitHandle()" label-width="90px">
                                                                            <el-form-item label="评论内容" prop="commentContent">
                        <el-input v-model="dataForm.commentContent" placeholder="请输入评论内容"></el-input>
                    </el-form-item>
                                                                <el-form-item label="用户编号" prop="userCode">
                        <el-input v-model="dataForm.userCode" placeholder="请输入用户编号"></el-input>
                    </el-form-item>
                                                                <el-form-item label="是否包含图片 1.是 2.否" prop="hasPicture">
                        <el-input v-model="dataForm.hasPicture" placeholder="请输入是否包含图片 1.是 2.否"></el-input>
                    </el-form-item>
                                                                <el-form-item label="图片地址" prop="picUrls">
                        <el-input v-model="dataForm.picUrls" placeholder="请输入图片地址"></el-input>
                    </el-form-item>
                                                                <el-form-item label="评分" prop="commentScore">
                        <el-input v-model="dataForm.commentScore" placeholder="请输入评分"></el-input>
                    </el-form-item>
                                                                <el-form-item label="评论类型 1.商品" prop="commentType">
                        <el-input v-model="dataForm.commentType" placeholder="请输入评论类型 1.商品"></el-input>
                    </el-form-item>
                                                                <el-form-item label="评论时间" prop="createTime">
                        <el-input v-model="dataForm.createTime" placeholder="请输入评论时间"></el-input>
                    </el-form-item>
                                                                <el-form-item label="回复时间" prop="replyTime">
                        <el-input v-model="dataForm.replyTime" placeholder="请输入回复时间"></el-input>
                    </el-form-item>
                                                                <el-form-item label="回复内容" prop="merchantReply">
                        <el-input v-model="dataForm.merchantReply" placeholder="请输入回复内容"></el-input>
                    </el-form-item>
                                        <el-form-item>
                <el-button @click="cancel">取消</el-button>
                <el-button type="primary"  @click="submit('dataForm')">确定</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</template>

<script>
    import {createGoodsComment} from '@/api/admin/goodsComment'
    export default{
        name: 'add-goodsComment',
        data(){
            return {
                dataForm: {
                                                                                                                    commentContent : ''
                                                                                                userCode : ''
                                                                                                hasPicture : ''
                                                                                                picUrls : ''
                                                                                                commentScore : ''
                                                                                                commentType : ''
                                                                                                createTime : ''
                                                                                                replyTime : ''
                                                                                                merchantReply : ''
                                                            },
                dataRule: {
                                                                                                                    commentContent: [
                            {
                                required: true,
                                message: '请输入评论内容',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                userCode: [
                            {
                                required: true,
                                message: '请输入用户编号',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                hasPicture: [
                            {
                                required: true,
                                message: '请输入是否包含图片 1.是 2.否',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                picUrls: [
                            {
                                required: true,
                                message: '请输入图片地址',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                commentScore: [
                            {
                                required: true,
                                message: '请输入评分',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                commentType: [
                            {
                                required: true,
                                message: '请输入评论类型 1.商品',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                createTime: [
                            {
                                required: true,
                                message: '请输入评论时间',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                replyTime: [
                            {
                                required: true,
                                message: '请输入回复时间',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                                                                merchantReply: [
                            {
                                required: true,
                                message: '请输入回复内容',
                                trigger: 'blur'
                            },
                            {
                                min: 3,
                                max: 20,
                                message: '长度在 3 到 20 个字符',
                                trigger: 'blur'
                            }
                        ]
                                                            }
            }
        },
        methods:{
            cancel(){
                this.$router.go(-1)
            },
            submit(){
                const set = this.$refs;
                set['dataForm'].validate((valid) => {
                    if (!valid) {
                        return false
                    }
                    createGoodsComment(this.dataForm).then(() => {
                        this.$notify({
                            title: '添加成功',
                            message: '添加成功',
                            type: 'success',
                            duration: 2000,
                            onClose: this.$router.go(-1)
                        })
                    })
                })
            }
        }
    }
</script>

<style>
</style>
